package Server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Date;
public class Server {
    Date timenow;
    public Server() {
        timenow = new Date();
        timenow.setMinutes(timenow.getMinutes() + 10);
    }

    public void start() {
        try {
            ServerSocket SerSocket = new ServerSocket(5555);
            Socket serverSocketAccepted;
            while (true) {
                Date nowcom = new Date();
                if (nowcom.before(timenow)) {
                    serverSocketAccepted = SerSocket.accept();
                    serverSocketAccepted.setSoTimeout(300000);
                    SThread st = new SThread(serverSocketAccepted);
                    st.start();
                } else {
                }
            }
        } catch (IOException e) {
            System.out.println("server listen exception:" + e);
        }
    }

    public static void main(String[] args) {
        Server S = new Server();
        System.out.print("Server run !!");
        S.start();
    }
}
